import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:member_center_sdk_example/components/loading_button.dart';

import 'action.dart';
import 'state.dart';

Widget buildView(
    SetPasswordByOldState state, Dispatch dispatch, ViewService viewService) {
  return Scaffold(
      appBar: AppBar(
        title: const Text('修改密码'),
      ),
      body: _buildBody(state, dispatch, viewService));
}

Widget _buildBody(
    SetPasswordByOldState state, Dispatch dispatch, ViewService viewService) {
  return Container(
    child: Column(
      children: <Widget>[
        Container(
          padding: EdgeInsets.all(15),
          child: TextField(
            controller: state.oldPwdController,
            obscureText: true,
            decoration:
                InputDecoration(icon: Icon(Icons.lock), labelText: "原密码"),
          ),
        ),
        Container(
          padding: EdgeInsets.all(15),
          child: TextField(
            controller: state.newPwdController,
            decoration:
                InputDecoration(icon: Icon(Icons.lock), labelText: "新密码"),
          ),
        ),
        new Container(
          child: LoadingButton("修改密码", state.isLoading, () {
            dispatch(SetPasswordByOldActionCreator.onSetPasswordAction());
          }),
        ),
      ],
    ),
  );
}
